<?php 

session_start();
if (!isset ($_SESSION["id"])) {
	session_destroy();
	echo "<script language='javascript'>top.location.href = 'Login.php';</script>";
	exit;
}

include_once 'public/DB_Oracle.php';
include_once 'public/page/page.class.php';
$DBsql = new DB_Oracle ();
$query=0;
if(isset($_GET['query'])){
$query=$_GET['query'];
}

	$sql="select * from GPS_CAR_USE_APPROVAL g ".($query==1?"where g.SQ_STATUS=0":($query==2?"where g.SQ_STATUS=1":""))." order by g.SQ_STATUS";/* where g.alarm_is_handel=0*/
	
	$rows=$DBsql->fetch_all_array($sql);
	$pageSize = 12;
	$total=count($rows)== 0 ? 1 : count($rows);
	//第一个0显示数字  第二个1显示概况 第三个显示下拉 第四个显示数字数量
	//print count($rows);
	pageft($total, $pageSize, 1, 1, 1, 5);
	$displaypg+=$firstcount;

?>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/validform.css" rel="stylesheet" type="text/css" />
<link href="public/page/css/css.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="js/Validform.js"></script>
<script language="javascript" type="text/javascript" src="js/public.js"></script>
<script language="javascript" type="text/javascript" src="js/date/WdatePicker.js"></script>
<style type="text/css">
 .highlight{ background:#ffff00; }
</style>
<script language='javascript'><!--
var flag=false;
	function sltItem(e){
		if(e.checked){
			document.getElementById("hidd").value+=",";
			document.getElementById("hidd").value+=e.value;
		}else{
			var str=document.getElementById("hidd").value;
			var checkValu=","+e.value;
			var valu=str.replace(checkValu,"");
			document.getElementById("hidd").value=valu;
		}
	}
	function setselectstate(){
		   if(flag){
			   var $aray = document.getElementsByName("selectID");
			   for(var i=0;i<$aray.length;i++){
						$aray[i].checked = false;
				}
			   flag=false;
		   }else{
			   var $aray = document.getElementsByName("selectID");
			   for(var i=0;i<$aray.length;i++){
						$aray[i].checked = true;
				}
				flag=true;
		   }
		   sltAll();
		}
	function sltAll(){
		var $aray = document.getElementsByName("selectID");
		var $str="";
		var sub=",";
		for(var i=0;i<$aray.length;i++){
			if($aray[i].checked){
				$str+=sub+$aray[i].value;
			}
		}
		if($str==","){
			$("#hidd").val("");
		}else{
			$("#hidd").val($str);
		}
	}
	function delChecked(){
		var id=$('#hidd').val();
		if(id==""){
			alert('请选择要处理条目');
		}else{
			sn=id.substr(1,id.length);
			delRow(sn);
		}
	}
		function chuliChecked(){
		var id=$('#hidd').val();
		if(id==""){
			alert('请选择要审核条目');
		}else{
			sn=id.substr(1,id.length);
			chuli(sn);
		}
	}
	//新建警员
	function POP(popDiv){
		POPdiv(popDiv);
		$('#add').focus();
	}
	$(function()
	{
		$('#List tr:gt(0)').click(
		function(){
		$('#List tr').removeClass("highlight");
		$(this).addClass("highlight");
		});
	});
	//修改警员信息
	function editRow(rowId){
		$('#upuser #sn').val(rowId);
		$.ajax({
			type:'POST',
			url:'approveCar.php',
			data:'act=select&sn='+rowId,
			dataType:'json',
			beforeSend:function(){
			},
			success:function(data){
				if(data!=null)$.each( data, function(i, p){if(isNaN(i))$('#UPdiv').find('#'+i).val(p);});
			},
			error:function(){
				alert('服务器繁忙！');
			},
			complete:function(){
				POPdiv('UPdiv');
				$('#up').focus();	
			}
		});
	}
	//删除区号信息
	function delRow(rowId){
		if(!confirm('您确定删除该用户信息吗？')){
			return false;
		}
		$.ajax({
			type:'POST',
			url:'approveCar.php',
			data:'act=del&sn='+rowId,
			success:function(data){
				if(data=='y'){
					$.Showmsg('删除成功！');
					setTimeout(function(){
					$.Hidemsg();
					window.location.reload();
				},1000);
				}else{
					$.Showmsg('删除失败！');
				}
			}	
		});
	}
	//处理警告信息
	function chuli(rowId){
		$.ajax({
			type:'POST',
			url:'approveCar.php',
			data:'act=chuli&sn='+rowId,
			success:function(data){
				if(data=='y'){
					$.Showmsg('审核成功！');
					setTimeout(function(){
					$.Hidemsg();
					window.location.reload();
				},1000);
				}else{
					$.Showmsg('审核失败！');
				}
			}	
		});
	}	
	$(function(){
		$("#adduser").Validform({
			 tiptype:2,
			   ajaxurl:"approveCar.php?act=add",
			   callback:function(data){
					if(data.status=="y"){
						//$.Showmsg(data.info);
						setTimeout(function(){
							$.Hidemsg();
							window.location.reload();
						},1000);
					}else{
						$.Showmsg(data.info);
					}
			   }
		});
	$("#upuser").Validform({
		 tiptype:2,
		   ajaxurl:"approveCar.php?act=up",
		   callback:function(data){
				if(data.status=="y"){
					$.Showmsg(data.info);
					$.Showmsg(data.info);
					setTimeout(function(){
						$.Hidemsg();
						window.location.reload();
					},1000);
				}else{
					$.Showmsg(data.info);
				}
		   }
	});
});

--></script>
<!--管理列表开始-->
<div class="manageTab">
  <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" class="usrTab">
    <tr>
      <td width="8" height="25"><img src="images/user_01.jpg" height="25" width="8" /></td>
      <td style="background:#3980b2;" valign="middle" height="16" ><div class="use_righgDiv"><span>
          <input type="checkbox" id="checkall" name="" value="" onclick="setselectstate()" />
          全选</span><span><img src="images/001.gif" height="14" width="14" /><a onclick="POP('POPdiv')" href="javascript:void(null)">新增</a></span><span><img src="images/037.gif" height="14" width="14" /><a onclick="chuliChecked()" href="javascript:void(null)">批量审批</a></span><span><img src="images/010.gif" height="14" width="14" /><a onclick="delChecked()" href="javascript:void(null)">批量删除</a></span><span></span></div>
        <div class="use_leftDiv">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td  width="22"><img src="images/311.gif" height="16" width="16" /></td>
              <td align="left"><span class="tdTit">车辆申请管理</span></td>
            </tr>
          </table>
        </div></td>
      <td width="8" height="25"><img src="images/user_02.gif" height="25" width="10" /></td>
    </tr>
    <tr>
      <td style="background:#3980b2;" >&nbsp;</td>
      <td><table width="100%" border="0" cellspacing="1" cellpadding="0" align="center" class="usrList" id="List">
          <tr>
            <td width="5%" class="td90b2">选择</td>
            <td width="9%" class="td90b2">申请ID</td>
            <td width="9%" class="td90b2">企业代号</td>
            <td width="9%" class="td90b2">出车单号</td>
            <td width="14%" class="td90b2">申请人ID</td>
            <td width="15%" class="td90b2">驾驶员</td>
            <td width="15%" class="td90b2">车牌号</td>
            <td width="8%" class="td90b2">审核</td>
            <td width="8%" class="td90b2">修改</td>
            <td width="8%" class="td90b2">删除</td>
            
          </tr>
          <?php if(count($rows)!=0){
          		foreach ($rows as $ros){
          	?>
          <tr id="List1">
            <td class="tdfff"><input type='checkbox' onclick='sltItem(this)' name="selectID" class="STYLE2" value="<?php echo $ros['ID'];?>" /></td>
            <td class="tdfff"><?php echo $ros['ID'];?></td>
            <td class="tdfff"><?php echo $ros['EN_ID'];?></td>
            <td class="tdfff"><?php echo $ros['OUT_CAR_NUMB'];?></td>
            <td class="tdfff"><?php echo $ros['USER_ID'];?></td>
            <td class="tdfff"><?php echo $ros['PILOTID'];?></td>
            <td class="tdfff"><?php echo $ros['CAR_ID'];?></td>
            <td class="tdfff"><div align="center"><img src="images/037.gif" width="9" height="9" /><span class="STYLE1"> [</span><a href="javascript:void(null)" onclick="<?php echo $ros['SQ_STATUS']==0?'chuli(\''.$ros['ID'].'\')':'return false;'; ?>"><?php echo ($ros['SQ_STATUS']==0?'审批':'已审批');?></a><span class="STYLE1">]</span></div></td>
            <td class="tdfff"><div align="center"><img src="images/a.gif".gif" width="9" height="9" /><span class="STYLE1"> [</span><a href="javascript:void(null)" onclick="editRow('<?php echo $ros['ID'];?>',this)">修改</a><span class="STYLE1">]</span></div></td>
            <td class="tdfff"><div align="center"><img src="images/010.gif" width="9" height="9" /><span class="STYLE1"> [</span><a href="javascript:void(null)" onclick="delRow('<?php echo $ros['ID'];?>')">删除</a><span class="STYLE1">]</span></div></td>
          </tr>
          <?php }}else{echo '暂无数据！';}?>
          <tr>
            <td colspan="10" class="tdfff">&nbsp;</td>
          </tr>
        </table></td>
      <td style="background:#3980b2;">&nbsp;</td>
    </tr>
    <tr>
      <td height="28" width="8"><img src="images/user_03.gif" height="28" width="8" /></td>
      <td style="background:#3980b2;"><div class="green-black" style=""><?php echo $pagenav;?></div></td>
      <td height="28" width="8"><img src="images/user_04.gif" height="28" width="8" /></td>
    </tr>
  </table>
</div>
<!--管理列表结束-->
<input type="hidden" id='hidd' value="" />
<!--弹出层新建用户开始-->
<div id="POPdiv" class="POPdiv">
  <div class="POPdiv_top"><a href="javascript:void(null)" onclick="ClosePOPdiv('POPdiv')"><img src="images/ico_close.jpg" alt="关闭" /></a>增加申请</div>
  <div class="POPdiv_content">
    <form class="adduser" id="adduser">
      <table border="0" cellpadding="5" cellspacing="0">
        <tr>
          <td width="100"><p >企业代号
              <label for="userNum">：</label>
            </p></td>
          <td><input type="text" ajaxurl="approveCar.php?act=valid" id="qiye" name='qiye' datatype="*2-8" nullmsg="请输入企业代号" errormsg='至少2~8个字符'/></td>
          <td><span class="Validform_checktip">至少2~8个字符</span></td>
        </tr>
        <tr>
          <td width="80"><p >出车单号
              <label for="chuche">：</label>
            </p></td>
          <td><input type="text" name='chuche' id="chuche" datatype="s" nullmsg="请输入出车单号" errormsg='至少2~4个字符'/></td>
          <td><span class="Validform_checktip">至少2~4个字符</span></td>
        </tr>
        <tr>
          <td width="80"><p >申请人
              <label for="shenqingren">：</label>
            </p></td>
          <td><input type="text" name='shenqingren' id="shenqingren" datatype="n" nullmsg="请输入申请人" errormsg='请输入数字'/></td>
          <td><span class="Validform_checktip">请输入数字</span></td>
        </tr>
        <tr>
          <td width="80"><p >车牌号
              <label for="userSex">：</label>
            </p></td>
          <td><input type="text" name='chepai' id="chepai" datatype="s" nullmsg="请输入车牌号" errormsg='至少2~4个字符'/></td>
          <td><span class="Validform_checktip">请输入车牌号</span></td>
        </tr>
        <tr>
          <td width="80"><p >目的地
              <label for="userNo">：</label>
            </p></td>
          <td><input type="text" name='mudi' id="mudi" datatype="s" nullmsg="请输入目的地" errormsg='至少6~10个字符'/></td>
          <td><span class="Validform_checktip">请输入目的地</span></td>
        </tr>
        <tr>
        <tr>
          <td width="80"><p >归还日期
              <label for="userNo">：</label>
            </p></td>
          <td><input id="guihuan" type="text" name="guihuan" datatype="s" nullmsg="请输入归还日期" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" errormsg='请输入日期' /></td>
          <td><span class="Validform_checktip">请输入日期</span></td>
        </tr>
        <tr>
          <td width="80"><p >事由
              <label for="work">：</label>
            </p></td>
          <td><input type="text" name='shiyou' id="shiyou" datatype="s" nullmsg="请输入事由" errormsg='至少6~10个字符'/></td>
          <td><span class="Validform_checktip"></span></td>
        </tr>
        <tr>
          <td colspan="3"><input name="" id="add" type="submit" class="btnbg" value="添加申请" style="width:70px; margin-left:80px; color:#FFF" /></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<!--弹出层新建用户结束--> 

<!--弹出层修改用户开始-->
<div id="UPdiv" class="POPdiv">
  <div class="POPdiv_top"><a href="javascript:void(null)" onclick="ClosePOPdiv('UPdiv')"><img src="images/ico_close.jpg" alt="关闭" /></a>修改人员信息</div>
  <div class="POPdiv_content">
    <form class="adduser" id="upuser">
    <input type='hidden' id='sn' name='sn' />
      <table border="0" cellpadding="5" cellspacing="0">
        <tr>
          <td width="100"><p >企业代号
              <label for="userNum">：</label>
            </p></td>
          <td><input type="text" ajaxurl="approveCar.php?act=valid" id="EN_ID" name='EN_ID' datatype="*2-8" nullmsg="请输入企业代号" errormsg='至少2~8个字符'/></td>
          <td><span class="Validform_checktip">至少2~8个字符</span></td>
        </tr>
        <tr>
          <td width="80"><p >出车单号
              <label for="chuche">：</label>
            </p></td>
          <td><input type="text" name='OUT_CAR_NUMB' id="OUT_CAR_NUMB" datatype="s" nullmsg="请输入出车单号" errormsg='至少2~4个字符'/></td>
          <td><span class="Validform_checktip">至少2~4个字符</span></td>
        </tr>
        <tr>
          <td width="80"><p >申请人
              <label for="shenqingren">：</label>
            </p></td>
          <td><input type="text" name='USER_ID' id="USER_ID" datatype="n" nullmsg="请输入申请人" errormsg='请输入数字'/></td>
          <td><span class="Validform_checktip">请输入数字</span></td>
        </tr>
        <tr>
          <td width="80"><p >车牌号
              <label for="userSex">：</label>
            </p></td>
          <td><input type="text" name='CAR_ID' id="CAR_ID" datatype="s" nullmsg="请输入车牌号" errormsg='至少2~4个字符'/></td>
          <td><span class="Validform_checktip">请输入车牌号</span></td>
        </tr>
        <tr>
          <td width="80"><p >目的地
              <label for="userNo">：</label>
            </p></td>
          <td><input type="text" name='ADDRESS' id="ADDRESS" datatype="s" nullmsg="请输入目的地" errormsg='至少6~10个字符'/></td>
          <td><span class="Validform_checktip">请输入目的地</span></td>
        </tr>
        <tr>
        <tr>
          <td width="80"><p >归还日期
              <label for="userNo">：</label>
            </p></td>
          <td><input id="GH_TIME" type="text" name="GH_TIME" datatype="s" nullmsg="请输入归还日期" class="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" errormsg='请输入日期' /></td>
          <td><span class="Validform_checktip">请输入日期</span></td>
        </tr>
        <tr>
          <td width="80"><p >事由
              <label for="work">：</label>
            </p></td>
          <td><input type="text" name='SUBJECT_MATTER' id="SUBJECT_MATTER" datatype="s" nullmsg="请输入事由" errormsg='至少6~10个字符'/></td>
          <td><span class="Validform_checktip"></span></td>
        </tr>
        <tr>
          <td colspan="3"><input name="" id="add" type="submit" class="btnbg" value="修改申请" style="width:70px; margin-left:80px; color:#FFF" /></td>
        </tr>
      </table>
      <input type="hidden" id="hiddUp" name="hiddUp"/>
    </form>
  </div>
</div>
<!--弹出层修改用户结束--> 
<!--弹出层选择派出所开始-->
<div id="selectLocation" class="POPdiv">
  <div class="POPdiv_top"><a href="javascript:void(null)" onclick="ClosePOPdiv('selectLocation')"><img src="images/ico_close.jpg" alt="关闭" /></a>分组查看</div>
  <div class="POPdiv_content">
    <form id="Location" action="user.php" method="get">
      <table border="0" cellpadding="5" cellspacing="0">
        <tr>
          <td width="80"><label for="selectID">选择派出所</label></td>
          <td><select id="selectID" name="selectID" onchange="groupSelect()">
              <option value="">全部</option>
              <?php 
					          	foreach ($dedp as $row){
					         ?>
              <option <?php if(isset($_GET['departmentID'])){if($_GET['departmentID']==$row['DEPARTMENT_INDEX']){echo 'selected=selected';}}?> value="<?php echo $row['DEPARTMENT_INDEX'];?>"><?php echo $row['DEPARTMENT_NAME'];?></option>
              <?php
					          	}
					         ?>
            </select></td>
          <td><input type="hidden" id="departmentID" name="departmentID" value=""></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<!--弹出层选择派出所结束-->